#模拟自动存取款机

#定义一个用于存放银行卡信息的列表变量
cardlist=[
	{'name':'zhangsan','ID':'123','password':'123','money':'1000'},
	{'name':'lisi','ID':'456','password':'456','money':'2000'},
	{'name':'wangwu','ID':'789','password':'789','money':'3000'}]
while True:
	#输出初始界面
	print("="*17,"自动存取款系统","="*17)
	print("{0:5}{1:20}".format(" ","1.登录"))
	print("{0:5}{1:20}{2:10}".format(" ","2.查询余额","3.取钱"))
	print("{0:5}{1:22}{2:10}".format(" ","4.存钱","5.退出"))
	print("="*50)
	key = input("请输入对应的选择：")
	#根据键盘值，判断并执行对应操作
	#登录功能
	if key == "1":
		print("="*17,"用户登录","="*17)
		IDkey = input("请输入账号：")
		passwordkey = input("请输入密码：")
		print("银行卡信息")
		if IDkey =="123" and passwordkey == "123":
			print("丨{0:<10}丨{1:<5}丨".format("name","ID"))
			print("-"*20)
			print("丨{0:<10}丨{1:<5}丨".format(cardlist[0]['name'],cardlist[0]['ID']))
		elif IDkey =="456" and passwordkey == "456":
			print("丨{0:<10}丨{1:<5}丨".format("name","ID"))
			print("-"*20)
			print("丨{0:<10}丨{1:<5}丨".format(cardlist[1]['name'],cardlist[1]['ID']))
		elif IDkey =="789" and passwordkey == "789":
			print("丨{0:<10}丨{1:<5}丨".format("name","ID"))
			print("-"*20)
			print("丨{0:<10}丨{1:<5}丨".format(cardlist[2]['name'],cardlist[2]['ID']))	
		else:
			print("="*17,"您输入的账号或密码错误，请重新输入","="*17)
		input("按回车键继续")
	#查询余额功能
	elif key == "2":
		print("="*17,"您的当前余额","="*17)
		if IDkey =="123" and passwordkey == "123":
			print("{0:<10}".format(cardlist[0]['money']))
		elif IDkey =="456" and passwordkey == "456":
			print("{0:<10}".format(cardlist[1]['money']))
		elif IDkey =="789" and passwordkey == "789":
			print("{0:<10}".format(cardlist[2]['money']))
		input("按回车键继续")
	#取款功能
	elif key == "3":
		if IDkey =="123" and passwordkey == "123":
			qukey = input("请输入取款金额：")
			if int(qukey)>1000:
				print("您的余额不足")
			elif int(qukey)<=1000:
				print("取款成功！您的账户总金额：",int(cardlist[0]['money'])-int(qukey))
		elif IDkey =="456" and passwordkey == "456":
			qukey = input("请输入取款金额：")
			if int(qukey)>2000:
				print("您的余额不足")
			elif int(qukey)<=2000:
				print("取款成功！您的账户总金额：",int(cardlist[1]['money'])-int(qukey))
		elif IDkey =="789" and passwordkey == "789":
			qukey = input("请输入取款金额：")
			if int(qukey)>3000:
				print("您的余额不足")
			elif int(qukey)<=3000:
				print("取款成功！您的账户总金额：",int(cardlist[2]['money'])-int(qukey))
		
		input("按回车键继续")
	#存款功能功能
	elif key == "4":
		if IDkey =="123" and passwordkey == "123":
			cukey = input("请输入存款金额：")
			print("存款成功！您的账户总金额：",int(cukey)+int(cardlist[0]['money']))
		elif IDkey =="456" and passwordkey == "456":
			cukey = input("请输入存款金额：")
			print("存款成功！您的账户总金额：",int(cukey)+int(cardlist[1]['money']))
		elif IDkey =="789" and passwordkey == "789":
			cukey = input("请输入存款金额：")
			print("存款成功！您的账户总金额：",int(cukey)+int(cardlist[2]['money']))
		input("按回车键继续")
	elif key == "5":
		print("="*17,"请取走卡片","="*17)
		break
	else:
		print("="*17,"无效的键盘输入","="*17)